<div class="gray_box">
    <?php include_partial('tabs', array('selected' => $sf_request->getParameter('action'))) ?>
    <div class="registration_wrap">
        <br/>
        <div class="inner_blue_title"><?php echo __('Personal Info') ?></div>
        <br/>
        <br/>
        <?php include('flashes.php') ?>
        <br/>
        <br/>
        <div class="registration_form_wrap">
                <table>
                    <tr>
                        <th style="padding-bottom:0"></th>
                        <td style="padding-bottom:0"><iframe scrolling="no" src="<?php echo url_for('user/profile_picture') ?>" name="upload_iframe" style="height: 108px; width: 116px;" ></iframe></td>
                    </tr>
                </table>
            <form id="upload_iframe_form" target="upload_iframe" action="<?php echo url_for('user/upload_picture') ?>" method="post" enctype="multipart/form-data">
                <?php echo $picture_form['_csrf_token'] ?>
                <table>
                    <tr>
                        <th></th>
                        <td><input name="profile_picture[file]" onchange="document.getElementById('upload_iframe_form').submit()" style="opacity: 0;position: absolute; cursor: pointer" size="1" type="file"/><button class="dbutton2"><?php echo __('Upload Photo') ?></button></td>
                    </tr>
                </table>
            </form>
            <?php echo $form->renderGlobalErrors() ?>
            <form method="post" action="<?php echo url_for('user/personal_info') ?>" method="post">
                <?php echo $form['_csrf_token'] ?>
                <?php echo $form['id'] ?>
                
                <table>
                    <tr>
                        <th><?php echo __('Name') ?></th>
                        <td><?php echo $form->getObject()->get('first_name') ?></td>
                    </tr>
                    <tr>
                        <th><?php echo __('Username') ?></th>
                        <td><?php echo $form->getObject()->get('username') ?></td>
                    </tr>
                    <tr>
                        <th><?php echo __('Email') ?></th>
                        <td><?php echo $form->getObject()->get('email_address') ?></td>
                    </tr>
                    <!--<tr>
                        <th><?php echo __('Password') ?></th>
                        <td><?php // echo $form['password']->render($form['password']->renderError() != '' ? array('class' => 'field_error') : array()) ?></td>
                    </tr>
                    <tr>
                        <th>Re-Enter Password</th>
                        <td><? // echo $form['password_again']->render($form['password_again']->renderError() != '' ? array('class' => 'field_error') : array()) ?></td>
                    </tr>-->
                    <tr>
                        <th><?php echo __('University') ?></th>
                        <td>
                            <div class="dos_select">
                                <?php if($form->getObject()->getUniversityId()){ ?>
                                    <?php echo $form->getObject()->getUniversity()->getName() ?>
                                <?php } else { ?>
                                    <?php echo $form['university_id']->render($form['university_id']->renderError() != '' ? array('class' => 'field_error') : array()) ?>
                                <?php } ?>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th><?php echo __('Faculty') ?></th>
                        <td>
                            <div class="dos_select">
                                <?php if($form->getObject()->getFacultyId()){ ?>
                                    <?php echo $form->getObject()->getFaculty()->getName() ?>
                                <?php } else { ?>
                                    <?php echo $form['faculty_id']->render($form['faculty_id']->renderError() != '' ? array('class' => 'field_error') : array()) ?>
                                <?php } ?>
                            </div>
                        </td>
                    </tr>
                </table>
                <div class="aright"><button class=dbutton><?php echo __('Save Info') ?></button></div>			
            </form>
        </div>
    </div>
</div>
<script>
     $('#sf_guard_user_university_id').change(function(){
         $.ajax({
            url: '<?php echo url_for('main/get_faculty_for_university') ?>?id='+$(this).val(),
            success: function(data) {
                $('#sf_guard_user_faculty_id').selectmenu('destroy');
                $('#sf_guard_user_faculty_id').html(data);
                $('#sf_guard_user_faculty_id').selectmenu({style:'dropdown'});
            }
        });
     });
     /*
     $('#sf_guard_user_faculty_id').change(function(){
        if($('#flashes').children().length == 0){
                $('#flashes').html('<div class="error">faculty change detected. chaning faculty will delete all your current courses under "My Doesyeh".</div>');
                $('body,html').animate({scrollTop: 0}, 800);
        }
     });
     */
     //<div class="error"><?php echo __('faculty change detected. save again to confirm. your courses will be deleted') ?></div>
     
//     current_value=$('#sf_guard_user_university_id').val();
//     $('#sf_guard_user_university_id').trigger('change');
//     $('#sf_guard_user_university_id').val(current_value);
</script>
    
    
    